import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


//一个恩尼格玛密码机由一个输入轮，三个转轮和一个反射板构成
public class EnigmaCoder {
    private InputWheel input;
    private Rotator r1,r2,r3;
    private Reflector ref;
    public EnigmaCoder(int num1,int num2,int num3) {
        Integer[] array = {1,24,25,9,10,11,12,4,19,20,21,26,0,5,6,7,8,22,23,15,16,13,14,2,3,17,18};

        List<Integer> list = new ArrayList<Integer>();
        Collections.addAll(list, array);
        input = new InputWheel();
        r1 = new Rotator(list,num1,1);
        r2 = new Rotator(list,num2,2);
        r3 = new Rotator(list,num3,3);
        ref = new Reflector();
    }
    String encode(String str) {
        String result = "";
        Character ch;
        int temp;
        for(int i = 0;i < str.length();i++) {
            ch = str.charAt(i);
            temp = ref.getNum(r3.getNum(r2.getNum(r1.getNum(input.inputChar(ch)))));
            temp = r1.getNumBack(r2.getNumBack(r3.getNumBack(temp)));
            ch = input.inputNum(temp);
            result += ch;
        }
        return result;
    }
    void setCoder(int num1,int num2,int num3) {
        r1.setPoint(num1);
        r2.setPoint(num2);
        r3.setPoint(num3);
    }
}